import { USERTOKEN, USERID, USERINFO, XSYC, TCDL } from '@/store/mkh/userxx/mutation-types'
import { Toast } from 'vant';
import { csh } from '@/api/dljk.js'
export default {
  namespaced: true,         //命名空间
  state: {
    xsyc: false,
    userInfo: {},
    uid: null,
    token: null
  },
  getters: {
  },
  mutations: { 
    [XSYC](a, val) {
      a.xsyc = val
    },
    [USERINFO](a, val) {
      a.userInfo = val
    },
    [USERID](a, val) {
      a.uid = val
    },
    [USERTOKEN](a, val) {
      a.token = val
    },
    [TCDL](state) {
      state.xsyc = false
      state.userInfo = {}
      state.uid = null
      state.token = null
    }
  },
  actions: {
    fhhs({commit}, token) {
      let jz = Toast.loading({
        message: '加载中，请稍等...',
        forbidClick: true,
      });
      csh(
        {
          token:token
        }
      ).then(res => {
        console.log(res)
        jz.clear()
        let { userInfo, uid } = res
        commit('XSYC', (true))
        commit('USERINFO', userInfo)
        commit('USERID', uid)
        commit('USERTOKEN', token)


      })
    }
  },
}